<template>
  <div class="serach">
    <!-- 顶部栏 -->
    <van-nav-bar title="搜索页" left-arrow @click-left="$router.back()" />
    <!-- 搜索框 -->
    <van-search
      v-model="value"
      show-action
      shape="round"
      autofocus
      placeholder="请输入搜索关键词"
      @search="onSearch"
      @input="onInput"
    >
      <template #action>
        <div @click="onSearch">搜索</div>
      </template>
    </van-search>
    <!-- 搜索列表 -->

    <!-- 打家都在搜 -->
    <div class="sr">
      <h3>大家都在搜索</h3>

      <span
        @click="$router.push({ path: '/labour', query: { id: item.id } })"
        v-for="(item, index) in suggestionlist"
        :key="index"
        class="custom-title"
        >{{ item }}</span
      >
    </div>
  </div>
</template>

<script>
import { getshareTopSearch } from "../../api/find";
export default {
  data() {
    return {
      value: "",
      suggestionlist: [],
    };
  },
  methods: {
    async onSearch() {
      const res = await getshareTopSearch();
      console.log(res);
      //绑定数据
      this.suggestionlist = res.data.data;
    },
  },
};
</script>

<style lang="less">
.serach {
  .sr {
    span {
      margin: 0 10px;
      width: 10px;
      height: 10px;
      background-color: #ccc;
    }
  }
}
</style>